/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.ittrick.drive.trick.factory;

import com.appspot.ittrick.drive.trick.model.FileModel;
import javafx.geometry.Pos;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.util.Callback;

/**
 *
 * @author imamura
 */
public class FileTableViewSizeFactory implements Callback<TableColumn, TableCell> {

    @Override
    public TableCell call(TableColumn p) {

        TableCell cell = new TableCell<FileModel, Long>() {
            @Override
            public void updateItem(Long item, boolean empty) {
                super.updateItem(item, empty);


                if (empty) {
                    setText(null);
                    setGraphic(null);
                } else {
                    setText(this.getItem() + " Byte");
                }
            }
        };

        cell.setAlignment(Pos.CENTER_RIGHT);

        return cell;
    }
}
